package org.example.yygh.hosp.controller;

import org.example.yygh.common.result.Result;
import org.example.yygh.hosp.service.IHospitalSetService;
import org.example.yygh.model.hosp.HospitalSet;
import org.example.yygh.vo.hosp.HospitalSetQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author hu
 * @version 1.0
 * @date 2021/3/13 0013 下午 3:24
 * @description
 */
@RestController
@RequestMapping("/hospital/set")
public class HospitalSetController {


    @Autowired
    private IHospitalSetService hospitalSetService;

    /**
     * 获取所有医院配置信息
     * @return
     */
    @RequestMapping("/list")
    public Result hospitalSetList() {
        return Result.ok(hospitalSetService.listsHospitalSet());
    }

    /**
     * 逻辑删除医院设置
     * @param id
     * @return
     */
    @PostMapping("/delete/{id}")
    public Result deleteHospital(@PathVariable Long id) {
        hospitalSetService.softDeleteHospitalById(id);
        return Result.ok();
    }

    /**
     * 分页查询
     * @param current
     * @param pageSize
     * @param hospitalSetQueryVo
     * @return
     */
    @RequestMapping("/page/{current}/pageSize")
    public Result findPageByHospitalQueryVo(@PathVariable int current, @PathVariable int pageSize,
                                            @RequestBody(required =  false) HospitalSetQueryVo hospitalSetQueryVo ){
        hospitalSetService.findPageByHospitalQueryVo(current, pageSize, hospitalSetQueryVo);
        return Result.ok();
    }

    /**
     * 保存医院设置
     * @param hospitalSet
     * @return
     */
    @PostMapping("/save")
    public Result saveHospitalSet(@RequestBody HospitalSet hospitalSet) {
        hospitalSetService.saveHospitalSet(hospitalSet);
        return Result.ok();
    }

    /**
     * 根据id 查询医院设置详情
     * @param id
     * @return
     */
    @RequestMapping("/detail/{id}")
    public Result findDetailById( @PathVariable Long id) {
        return Result.ok(hospitalSetService.findDetailById(id));
    }

    @PostMapping("/edit")
    public Result edit(@RequestBody HospitalSet hospitalSet) {
        return Result.ok();
    }
}
